﻿using System;
using System.Collections;
using UnityEngine;

namespace UI
{
    public class UIAnimation : MonoBehaviour, IUIAnimation
    {
        public IEnumerator PlayHide()
        {
            Debug.Log("开始播放隐藏动画");
            float t = 0;
            transform.localScale = Vector3.one;
            while (t < 1)
            {
                var size =1- Mathf.Lerp(0, 1, t);
                transform.localScale = new Vector3(size, size, size);
                yield return 0;
                t += Time.deltaTime*3;
            }
            transform.localScale = Vector3.zero;
            Debug.Log("隐藏动画播放完毕");
        }

        public IEnumerator PlayShow()
        {
            float t = 0;
            transform.localScale = Vector3.zero;
            while (t < 1)
            {
                var size = Mathf.Lerp(0, 1, t);
                transform.localScale = new Vector3(size, size, size);
                yield return 0;
                t += Time.deltaTime * 3;
            }
            transform.localScale = Vector3.one;
        }
    }

}
